home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS01.ADF / Text / Sounds < prev    next >
Internet Message Format  |  1985-12-04  |  5KB

  1. From bobp@amiga.UUCP (Robert S. Pariseau) Fri Nov  8 13:00:10 1985
  2. Path: gumby!uwvax!seismo!caip!topaz!packard!hoxna!houxm!ihnp4!nsc!pyramid
  3.         !amiga!bobp
  4. From: bobp@amiga.UUCP (Robert S. Pariseau)
  5. Newsgroups: net.micro.amiga
  6. Subject: Sampled Sounds File Format
  7. Date: 8 Nov 85 19:00:10 GMT
  8. Reply-To: bobp@snake.UUCP (Robert S. Pariseau)
  9. Organization: Commodore-Amiga Inc., 983 University Ave #D, Los Gatos CA 95030
  10.  
  11. I've received some mail asking for this stuff, so here's a copy of a
  12. posting I made to BIX recently:
  13.  
  14. =================================
  15.  
  16. TITLE:  Sampled Sound Data Files
  17.  
  18. This note (ahem) describes the format of the sampled sound data files found 
  19. on the instruments disk which is used with the Music demo on the dealer's 
  20. Workbench Demo Disk.  This stuff is lifted from the musty files of 
  21. Sam-the-audio-expert.  If you don't understand some of the terminology used, 
  22. you're out of luck until Sam-tae returns from vacation.  
  23.         
  24. I've looked at the source for the Music demo and, like all our demo code (see 
  25. comment elsewhere in this conference), it's full of bees and spiders!  That's 
  26. why we don't give it out.  In any event, I'll do my best to guide you.  Hold 
  27. on tightly now....
  28.  
  29. Each sampled sound begins with the CompressedSample header described below.  
  30. Each sound is comprised of one or more octaves.  Each octave is comprised of 
  31. one or more segments.  A segment contains 2**N cycles of the waveform in 
  32. tune, usually bounded by zero crossings.  The sampled sound may designate the 
  33. ending segments as looping segments. The looping and unlooping segments are 
  34. not to be confused with an envelope or ADSR.  An ADSR envelope is independent 
  35. and controlled with variables in the Note structure.  These segments will be 
  36. played repeatedly during the Sustain and Release of the note.
  37.  
  38. Each octave's segment size is twice as large as the octave above it.
  39.  
  40. Example:
  41.  
  42. highOctSize = 4;
  43. lowOctSize = 7;
  44. numSegments = 5;
  45. loopStart = 3;
  46.  
  47. If each digit below represents 16 bytes of data, then each segment would take 
  48. the space indicated by the number of digits with the segment number.  
  49. Segments 3 & 4 of an octave would be repeated for looping.
  50.  
  51.                             ____
  52.                            /     \  loop
  53.                            V      |
  54. 012340011223344000011112222333344440000000011111111222222223333333344444444
  55. \   /\__   __/\___________________/\_______________        _______________/
  56.  \ /    \ /                                        \      /
  57. highest next                                        lowest
  58. octave  octave                                      octave
  59.  
  60. <--low memory                    . . .                       high memory-->
  61.  
  62. The notes for a given octave are produced by playing the sample for that 
  63. octave at a sampling rate of between 14 and 28KHz (one octave).  The Music 
  64. demo uses a trivial Vertical Blank Interrupt Server to signal it regularly 
  65. once per video frame.  These "ticks" are used to advance through the ADSR 
  66. envelope described in the Note structure.  Envelope generation is done by 
  67. issuing the appropriate audio device command to change audio channel volume.
  68.  
  69. The actual period values used to produce the scale are
  70. 240, 226, 214, 202, 190, 180, 170, 160, 151, 143, 135, 127.
  71.  
  72. The meanings of Very Slow to Very Fast attack, decay, and release are built 
  73. into the Music demo -- as are the default settings of these for each 
  74. instrument.  Sustain is determined by how long the player keeps the key 
  75. depressed.
  76.  
  77. For more info on all of this, refer to the Amiga Hardware Manual and the 
  78. Amiga ROM Kernel Manual.
  79.  
  80. --------------------------Sampled sound header file
  81.  
  82. /* The looping octaves technique number */
  83. #define TL_LOOPING_OCTAVES      1
  84.  
  85. #define MAX_SAMPLE_SIZE (sizeof(struct CompressedSample)+2*128*128)
  86.  
  87.  
  88. /* compressed sampled sound data structure */
  89.  
  90. /* THIS IS THE HEADER ON A SAMPLED SOUND DATA FILE */
  91.  
  92. struct CompressedSample {
  93.     UWORD technique;    /* technique number */
  94.     UWORD numSegments;  /* number of segments in sample (same for all octaves)*/
  95.     UWORD loopStart;    /* first segment of loop (= numSegments for no loop) */
  96.     UBYTE highOctSize;  /* highest octave segment size (power of 2) */
  97.     UBYTE lowOctSize;   /* lowest octave segment size (power of 2) */
  98.     BYTE samples[1];    /* start of samples */
  99. };
  100.  
  101. /* note descriptor */
  102.  
  103. /* THIS STRUCTURE IS USED TO KEEP ADSR INFO WITH A SOUND IN MEMORY */
  104.  
  105. struct Note {
  106.     struct CompressedSample *sample;    /* sound sample in compressed format */
  107.     UWORD attack;       /* attack time in msec. (0 - 65535) */
  108.     UWORD decay;        /* decay time in msec., 0 for sustain (1 - 65535) */
  109.     UWORD release;      /* release time in msec. (0 - 65535) */
  110.     UBYTE channel;      /* audio channel number (0 - 3) */
  111.     UBYTE pitch;        /* note number, 0 for A (0 - highest octave of sound) */
  112.     UBYTE level;        /* sustain level in 0.1875 db steps (0 - 255) */
  113.     UBYTE vibDepth;     /* vibrato depth, up to one whole step (0 - 255) */
  114.     UBYTE vibRate;      /* vibrato rate, (0 - 255) */
  115. };
  116.  
  117.